// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed partial class DataframeAnalyticsDestination
	{
		[JsonInclude]
		[JsonPropertyName("index")]
		public Elastic.Clients.Elasticsearch.IndexName Index { get; set; }

		[JsonInclude]
		[JsonPropertyName("results_field")]
		public Elastic.Clients.Elasticsearch.Field? ResultsField { get; set; }
	}

	public sealed partial class DataframeAnalyticsDestinationDescriptor<TDocument> : SerializableDescriptorBase<DataframeAnalyticsDestinationDescriptor<TDocument>>
	{
		internal DataframeAnalyticsDestinationDescriptor(Action<DataframeAnalyticsDestinationDescriptor<TDocument>> configure) => configure.Invoke(this);
		public DataframeAnalyticsDestinationDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.IndexName IndexValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? ResultsFieldValue { get; set; }

		public DataframeAnalyticsDestinationDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			IndexValue = index;
			return Self;
		}

		public DataframeAnalyticsDestinationDescriptor<TDocument> ResultsField(Elastic.Clients.Elasticsearch.Field? resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		public DataframeAnalyticsDestinationDescriptor<TDocument> ResultsField<TValue>(Expression<Func<TDocument, TValue>> resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("index");
			JsonSerializer.Serialize(writer, IndexValue, options);
			if (ResultsFieldValue is not null)
			{
				writer.WritePropertyName("results_field");
				JsonSerializer.Serialize(writer, ResultsFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class DataframeAnalyticsDestinationDescriptor : SerializableDescriptorBase<DataframeAnalyticsDestinationDescriptor>
	{
		internal DataframeAnalyticsDestinationDescriptor(Action<DataframeAnalyticsDestinationDescriptor> configure) => configure.Invoke(this);
		public DataframeAnalyticsDestinationDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.IndexName IndexValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field? ResultsFieldValue { get; set; }

		public DataframeAnalyticsDestinationDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			IndexValue = index;
			return Self;
		}

		public DataframeAnalyticsDestinationDescriptor ResultsField(Elastic.Clients.Elasticsearch.Field? resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		public DataframeAnalyticsDestinationDescriptor ResultsField<TDocument, TValue>(Expression<Func<TDocument, TValue>> resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		public DataframeAnalyticsDestinationDescriptor ResultsField<TDocument>(Expression<Func<TDocument, object>> resultsField)
		{
			ResultsFieldValue = resultsField;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("index");
			JsonSerializer.Serialize(writer, IndexValue, options);
			if (ResultsFieldValue is not null)
			{
				writer.WritePropertyName("results_field");
				JsonSerializer.Serialize(writer, ResultsFieldValue, options);
			}

			writer.WriteEndObject();
		}
	}
}